#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int prev=0, s, time = 0;
	while (scanf("%d", &s))
	{
		if (s == 0) break;
		else
		{
			if (s > prev)
			{
				time += (s - prev) * 6 + 5;
			}
			else if (s < prev)
			{
				time += (prev - s) * 4 + 5;
			}
			prev = s;
		}
	}
	printf("%d", time);
}